package com.brisk.web.controller.applet;

import com.ruoyi.applet.domain.AppletWalkRow;
import com.ruoyi.applet.service.IAppletWalkRowService;
import com.brisk.common.annotation.Log;
import com.brisk.common.core.controller.BaseController;
import com.brisk.common.core.domain.AjaxResult;
import com.brisk.common.core.page.TableDataInfo;
import com.brisk.common.enums.BusinessType;
import com.brisk.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * appletWalkRowController
 *
 * @author PENGFEIDENG
 * @date 2022-06-01
 */
@RestController
@RequestMapping("/applet/appletWalkRow")
public class AppletWalkRowController extends BaseController {
    @Autowired
    private IAppletWalkRowService appletWalkRowService;


    /**
     * 获取近15天兑换
     *
     * @return com.ruoyi.common.core.domain.AjaxResult
     * @author PengFei Deng
     * @date 2022/6/3 11:06
     */
    @GetMapping("getWalkRowChar")
    public AjaxResult getWalkRowChar() {
        return AjaxResult.success(appletWalkRowService.getWalkRowChar());
    }


    /**
     * 查询appletWalkRow列表
     */
    @PreAuthorize("@ss.hasPermi('applet:appletWalkRow:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletWalkRow appletWalkRow) {
        startPage();
        List<AppletWalkRow> list = appletWalkRowService.selectAppletWalkRowList(appletWalkRow);
        return getDataTable(list);
    }

    /**
     * 导出appletWalkRow列表
     */
    @PreAuthorize("@ss.hasPermi('applet:appletWalkRow:export')")
    @Log(title = "appletWalkRow", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppletWalkRow appletWalkRow) {
        List<AppletWalkRow> list = appletWalkRowService.selectAppletWalkRowList(appletWalkRow);
        ExcelUtil<AppletWalkRow> util = new ExcelUtil<AppletWalkRow>(AppletWalkRow.class);
        util.exportExcel(response, list, "appletWalkRow数据");
    }

    /**
     * 获取appletWalkRow详细信息
     */
    @PreAuthorize("@ss.hasPermi('applet:appletWalkRow:query')")
    @GetMapping(value = "/{rowId}")
    public AjaxResult getInfo(@PathVariable("rowId") Long rowId) {
        return AjaxResult.success(appletWalkRowService.selectAppletWalkRowByRowId(rowId));
    }

    /**
     * 新增appletWalkRow
     */
    @PreAuthorize("@ss.hasPermi('applet:appletWalkRow:add')")
    @Log(title = "appletWalkRow", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletWalkRow appletWalkRow) {
        return toAjax(appletWalkRowService.insertAppletWalkRow(appletWalkRow));
    }

    /**
     * 修改appletWalkRow
     */
    @PreAuthorize("@ss.hasPermi('applet:appletWalkRow:edit')")
    @Log(title = "appletWalkRow", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletWalkRow appletWalkRow) {
        return toAjax(appletWalkRowService.updateAppletWalkRow(appletWalkRow));
    }

    /**
     * 删除appletWalkRow
     */
    @PreAuthorize("@ss.hasPermi('applet:appletWalkRow:remove')")
    @Log(title = "appletWalkRow", businessType = BusinessType.DELETE)
    @DeleteMapping("/{rowIds}")
    public AjaxResult remove(@PathVariable Long[] rowIds) {
        return toAjax(appletWalkRowService.deleteAppletWalkRowByRowIds(rowIds));
    }
}
